package com.jsfcompref.solutech.backing;


import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlInputSecret;
import javax.faces.component.html.HtmlInputText;
import javax.faces.context.FacesContext;
import javax.faces.validator.ValidatorException;


/**
 * Backing bean for register.jsp
 */



public class Register 
{
  
  private HtmlInputText firstName;
  private HtmlInputText lastName;
  private HtmlInputText email;
  private HtmlInputText dob;
  private HtmlInputText address;
  private HtmlInputText phoneNum;
  private HtmlInputText userid;
  private HtmlInputSecret password;
  private HtmlInputSecret passwordCheck;
  

  public Register()
  {
  }

  public void validateEmail(FacesContext context, UIComponent toValidate,
                            Object value) throws ValidatorException {
    String eMail = (String) value;
    if(eMail.indexOf("@")<0) {
      FacesMessage message = new FacesMessage("Invalid email address!");
      throw new ValidatorException(message);
    }
  }


  public void validatePassword(FacesContext context, UIComponent toValidate,
                            Object value) throws ValidatorException {
    
    String password1 = (String)this.getPassword().getValue();
    String password2 = (String) value;
        
    if(!password1.equals(password2)) {
      FacesMessage message = new FacesMessage("Passwords do not match!");
      throw new ValidatorException(message);
    }
  }

  
 public String registerUser()
 {

    return("confirm");
  
  }

public HtmlInputText getDob() {
	return dob;
}

public void setDob(HtmlInputText dob) {
	this.dob = dob;
}

public HtmlInputText getAddress() {
	return address;
}

public void setAddress(HtmlInputText address) {
	this.address = address;
}

public HtmlInputText getPhoneNum() {
	return phoneNum;
}

public void setPhoneNum(HtmlInputText phoneNum) {
	this.phoneNum = phoneNum;
}

  public void setFirstName(HtmlInputText firstName) {
    this.firstName = firstName;
  }

  public HtmlInputText getFirstName() {
    return firstName;
  }

  public void setLastName(HtmlInputText lastName) {
    this.lastName = lastName;
  }

  public HtmlInputText getLastName() {
    return lastName;
  }



  public void setEmail(HtmlInputText email) {
    this.email = email;
  }

  public HtmlInputText getEmail() {
    return email;
  }


  public void setUserid(HtmlInputText userid) {
    this.userid = userid;
  }

  public HtmlInputText getUserid() {
    return userid;
  }

  public void setPassword(HtmlInputSecret password) {
    this.password = password;
  }

  public HtmlInputSecret getPassword() {
    return password;
  }



  public void setPasswordCheck(HtmlInputSecret passwordChk) {
    this.passwordCheck = passwordChk;
  }

  public HtmlInputSecret getPasswordCheck() {
    return passwordCheck;
  }


}
